package com.zeus.monitor.commmon.utils;

import com.hengxinyongli.zeus.common.dto.result.Result;
import com.hengxinyongli.zeus.common.dto.result.ResultCode;
import com.zeus.monitor.zeus.common.utils.ValidatorUtils;
import org.hibernate.validator.constraints.NotEmpty;

/**
 * 验证工具Demo
 */
public class ValidatorUtilsDemo {

    public static void main(String[] args) {
        ContactInfo contactInfo = new ContactInfo();
        contactInfo.setName("测试");
        ValidatorUtils.ValidatorResult validatorResult = ValidatorUtils.validate(contactInfo);
        if(validatorResult.failed()){
            Result<Long> fail = Result.<Long>create().fail(ResultCode.PARAM_ERROR.getCode(), validatorResult.getDescription());
            System.out.println(fail);
        }
    }

    public static class ContactInfo {
        @NotEmpty
        private String mobile;//手机号
        @NotEmpty
        private String name;//姓名

        public String getMobile() {
            return mobile;
        }

        public void setMobile(String mobile) {
            this.mobile = mobile;
        }

        public String getName() {
            return name;
        }

        public void setName(String name) {
            this.name = name;
        }
    }
}
